package oop.core.view;

import java.awt.BorderLayout;

import javax.swing.JFrame;

import oop.core.entity.Avatar;
import oop.core.entity.MerchantNPC;
import oop.core.med.TransactionMediator;
import oop.core.view.listeners.BuyingInventoryListener;
import oop.core.view.listeners.SellingInventoryListener;

/**
 * 
 * Where Merchant and NPC interact
 * Where buy/trade/sale occurs
 *
 */
public class MerchantInteractionMenu extends JFrame {
	
	private TransactionMediator transactionMediator;
	private Avatar avatar;
	private MerchantNPC merchant;
	
	public MerchantInteractionMenu(TransactionMediator transactionMediator, Avatar avatar, MerchantNPC merchant)
	{
		this.transactionMediator = transactionMediator;
		this.avatar = avatar;
		this.merchant = merchant;
		
		// REUSABILITY AT IT'S FINEST! YEAAAAHH!
		InventoryPanel merchantPanel = new InventoryPanel();
		merchantPanel.takeInventory(merchant.getInventory());
		
		InventoryPanel avatarPanel = new InventoryPanel();
		avatarPanel.takeInventory(avatar.getInventory());
		

		this.setTitle("Avatar      |  Merchant");
		this.setSize(avatarPanel.getDimension().width*2, avatarPanel.getDimension().height);
		this.setLocation(avatar.getLoc().getXPos()*40, avatar.getLoc().getYPos()*40);
		this.setLayout(new BorderLayout());
		
		this.add(merchantPanel, BorderLayout.WEST);
		this.add(avatarPanel, BorderLayout.EAST);
		this.setVisible(true);

		merchantPanel.addMouseListener(new BuyingInventoryListener(transactionMediator));
		avatarPanel.addMouseListener(new SellingInventoryListener(transactionMediator));

	}
}
